package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.login.SMSCodeBean;
import com.xinfu.newproject.bean.login.SMSCodeBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.login.SMSCodeModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class SMSCodePresenter {
    private IView.ISMSCodeView mISMSCodeView;

    SMSCodeModel mSmsCodeModel;
    //  private LoginModel mPhoneModel;

    public SMSCodePresenter(IView.ISMSCodeView ismsCodeView) {
        this.mISMSCodeView = ismsCodeView;
        mSmsCodeModel = new SMSCodeModel();
    }

    /**
     * 登录
     */
    public void getSMSCode() {
      /*  Map<String, String> paraMap =new HashMap<>();
        paraMap.put("userName",mIPhoneView.getUserName());
        paraMap.put("passWord",mIPhoneView.getPassWord());*/
        mISMSCodeView.showProgress();

        SMSCodeBody smsCodeBody = new SMSCodeBody(mISMSCodeView.getUserName());

        mSmsCodeModel.getSMSCode(smsCodeBody, new MyCallBack<SMSCodeBean>() {
            @Override
            public void onSuccess(SMSCodeBean smsCodeBean) {
                mISMSCodeView.hideProgress();
//                if (userPhoneBean.getCode() == 0) {
//                    if (userPhoneBean.isSuccess()){
//                        mISMSCodeView.getMsg(userPhoneBean.getMessage());
//                    }else {
//                        mISMSCodeView.getMsg(userPhoneBean.getMessage());
//                    }

//                }
//                mISMSCodeView.showToast(userPhoneBean.getMessage());
//                Log.i("testPhone","success="+userPhoneBean.isSuccess()+"code="+userPhoneBean.getCode()+"message="+userPhoneBean.getMessage()+"result="+userPhoneBean.getResult());
            }

            @Override
            public void onError(String header, String message) {
                mISMSCodeView.hideProgress();
                mISMSCodeView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mISMSCodeView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
